<template>
  <div>
    <div class="top">
      <img
        src="http://liufusong.top:8080/img/profile/bg.png"
        id="topImg"
        alt=""
      />
      <div class="main">
        <van-image
          round
          width="5rem"
          height="5rem"
          src="http://liufusong.top:8080/img/profile/avatar.png"
        />
        <div class="user_name">游客</div>
        <van-button type="primary" @click="goLogin" class="Login"
          >去登录</van-button
        >
      </div>
    </div>

    <van-grid :column-num="3" class="grid" clickable>
      <van-grid-item
        v-for="(item, index) in list"
        :key="index"
        :icon="item.icon"
        :text="item.text"
        @click="goRouter(index)"
      />
    </van-grid>
    <img
      src="http://liufusong.top:8080/img/profile/join.png"
      id="botImg"
      alt=""
    />
  </div>
</template>

<script>
export default {
  name: 'UserPage',
  data () {
    return {
      list: [
        {
          icon: 'star-o',
          text: '我的收藏'
        },
        {
          icon: 'wap-home-o',
          text: '我的出租'
        },
        {
          icon: 'underway-o',
          text: '看房记录'
        },
        {
          icon: 'notes-o',
          text: '成为房主'
        },
        {
          icon: 'contact',
          text: '个人资料'
        },
        {
          icon: 'service-o',
          text: '联系我们'
        }
      ]
    }
  },
  methods: {
    goLogin () {
      this.$router.push('/login')
    },
    goRouter (index) {
      if (index === 0) {
        this.$router.push('/collection')
      } else if (index === 1) {
        this.$router.push('/rent')
      }
    }
  }
}
</script>

<style scoped>
* {
  box-sizing: border-box;
}
.top {
  position: relative;
}
.grid {
  margin-top: 130px;
}
#topImg {
  width: 100%;
  height: 100%;
  overflow-clip-margin: content-box;
  overflow: clip;
}
#botImg {
  width: 90%;
  margin: 20px;
}
.main {
  background-color: #fff;
  position: absolute;
  z-index: 1;
  height: 230px;
  width: 330px;
  display: flex;
  flex-direction: column;
  justify-content: space-evenly;
  align-items: center;
  margin: -120px 20px 20px;
  border: 1px solid #ddd;
  box-shadow: 0 0 10px 3px #ddd;
  font-size: 13px;
}
.Login {
  width: 80px;
  height: 30px;
}
</style>
